//
//  ViewController.swift
//  xtools
//
//  Created by symbol on 2018/4/12.
//  Copyright © 2018年 symbol. All rights reserved.
//

import Cocoa

class ViewController: NSViewController {
    
    //界面加载完成后修改主面板信息
    override func viewDidAppear(){
        self.view.window?.title = "波妞工具箱"
        self.view.layer?.backgroundColor = NSColor.clear.cgColor
        //加载默认的数据
        function()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    override var representedObject: Any? {
        didSet {
        // Update the view, if already loaded.
        }
    }

    //关联数据
    @IBOutlet weak var popUpButton: NSPopUpButton!
    
    //设置入口的方法
    func function() {
        let items = ["Jfinal","Other"]
        //删除默认数据
        self.popUpButton.removeAllItems()
        //追加数据【数组形式】
        self.popUpButton.addItems(withTitles: items)
        //设置默认选中数据
        self.popUpButton.selectItem(at: 0)
    }
    
    //确认动作[暂时没什么鸟用]
    @IBAction func up(_ sender: Any) {
        let items = popUpButton.itemTitles
        let num = popUpButton.indexOfSelectedItem
        //确认数据
        //print(value[num])
        let value = items[num]
        switch value {
        case "Jfinal":
            //唤起另一个面板
            print("test")
            
            //关闭当前面板
            //self.view.window?.close()
            break
        default:
            //弹出提示
            tjil()
            break
        }
    }
    

    
    //弹窗操作
    func tjil(){
        let alert = NSAlert()
        //增加一个按钮
        alert.addButton(withTitle: "确定")
        //提示标题
        alert.messageText = "警告"
        //提示详细内容
        alert.informativeText = "客官莫急，还没有准备好。。。"
        //设置警告框风格
        alert.alertStyle = .critical
        alert.beginSheetModal(for: self.view.window!)
    }
}
